// common
package form

import (
	"github.com/martini-contrib/binding"
	"martini_template/componnet"
	"mime/multipart"
	"net/http"
)

type UploadForm struct {
	UpFile        *multipart.FileHeader `form:"upload_file"`
	NewName       string                `form:"new_name"`
	IsImage       int                   `form:"is_image"`
	MakeThumbnail int                   `form:"make_thumbnail"`
}

func (uf *UploadForm) Validate(errors binding.Errors, req *http.Request) binding.Errors {
	uf.NewName = componnet.FilterString(uf.NewName)
	return errors
}

type LogForm struct {
	OperId    string `form:"oper_id"`
	OpAction  string `form:"op_action"`
	OpType    string `form:"op_type"`
	OpIP      string `form:"op_ip"`
	OpContent string `form:"op_content"`
	OpTime    int64  `form:"op_time"`
}

type AccessTokenForm struct {
	AccessToken string `form:"access_token"`
}

func (af *AccessTokenForm) Validate(errors binding.Errors, req *http.Request) binding.Errors {
	af.AccessToken = componnet.FilterString(af.AccessToken)
	return errors
}
